package com.cn.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.cn.domain.Product;
import com.cn.service.ProductService;
import com.cn.service.impl.ProductServiceImpl;

public class ProductDetailServlet extends BaseServlet {

	//private ProductService ps = new ProductServiceImpl();
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		String id = request.getParameter("id");
		Product p = ps.getProductById(Integer.parseInt(id));
		request.setAttribute("product", p);
		request.getRequestDispatcher("product_info.jsp").forward(request, response);
	}

}
